<extend name="Public/layout"/>
<block name="head">
          <link rel="stylesheet" href="__PUBLIC__css/message-index.css?a=<php>echo time()</php>">
          <script src="http://www.jq22.com/jquery/1.9.1/jquery.min.js"></script>
          <script src="https://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<style type="text/css">
 
</style>
</block>
<block name="main">
        <div class="nav_top">
            <ul>
                <li onclick="location.href='/Home/Person/interact_message'">
                  <a href="javascript:;">
                    <div class="nav_img"> <img src="__PUBLIC__images/icon_xx_hud_nor.png" width="100%" height="100%"> </div>
                    <!-- <div class="is_read"></div> -->
                    <span>互动通知</span>
                  <a>
                </li>

                <li onclick="location.href='/Home/Person/notice/val/2'">
                  <a href="javascript:;">
                    <div class="nav_img"> <img src="__PUBLIC__images/icon_xx_mes_nor.png"  width="100%" height="100%"> </div>
                    <div  <if condition='$unread'>class="is_read"></if></div>
                    <span>站内信</span>
                  </a>
                </li>

                <li onclick="location.href='/Home/Person/notice/val/1'">
                  <a href="javascript:;">
                    <div class="nav_img"> <img src="__PUBLIC__images/icon_xx_gg_nor.png"  width="100%" height="100%"> </div>
                    <div  <if condition='$notice_reads eq 1'>class="is_read"</if> ></div>
                    <span>平台公告</span>
                  </a>
                </li>
            </ul>

        </div>

        <div class="im_chat">
          <div class="chat_title">
          <span class="caht_title">聊天列表</span>
          <input type="text" class="search-inp" name="" placeholder="搜索">
          <a href="javascript:" class="a_seach" onclick="to_seach(this)"><img src="__PUBLIC__images/icon_serch_nor.png" width="100%" height="100%"></a>
          <div class="close_seach" onclick="to_seach(this)">取消</div>
          </div>
          <div class="chat-con">
            <div class="chat-list" id="list">
              <ul>
                <foreach name="chat" item="v">
                    <li>
                      <div class="chat-item clearfix " <if condition="$v.type eq 2"> onclick="location.href='/Home/Im/group/id/{$v.group_info.platform_id}'" 
                      <elseif condition="$v.type eq 3"/>onclick="location.href='/Home/Im/group/id/{$v.group_main}/pushid/{$v.group_main}'"
                      <else/> onclick="location.href='/Home/Im/talk/id/{$v.user_info.id}'" </if> >
                        <div class="chat-left">
                          <div class="chat-icon">
                            <if condition="$v.type eq 2 || $v.type eq 3"><img src="__PUBLIC__images/chat-icon.png"><else/><img src="{$v.user_info.url_img}"></if>
                          </div>

                        </div>
                        <div class="chat-right">
                          <h4><if condition="$v.type eq 2">{$v.group_info.name}<elseif condition="$v.type eq 1"/>{$v.user_info.nickname}<else/><if condition="$v.group_main eq $user.id"> 我的投顾的群 <else/> 师父的群 </if></if></h4>
                          <p><if condition="$v.lats_chat.content">{$v.lats_chat.content}<else/>暂无新消息</if></p>
                        </div>
                      </div>
                      <a class="delete">删除</a>
                      <a class="delete-sure" attr_type="{$v.type}"  attr_id = "{$v.type}">确认删除</a>
                    </li>
                </foreach>

              </ul>
            </div>

          </div>
        </div>
		  <div class="base-line clearfix">
        <span class="base-left"></span>
        <p>我是有底线的</p>
        <span class="base-right"></span>
      </div>
		<div style="width:100%;height:2.5rem; float:left"></div>
</block>
<block name="js">
    <script type="text/javascript">
        function to_seach(obj){
          var is_show=$(obj).prev().prev('span').css('display');
          if(is_show=="block"){
            $('.caht_title').hide();
            $('.search-inp').show();
            $(obj).hide();
           $('.close_seach').show();
          }else{
           $('.caht_title').show();
           $(obj).hide();
           $('.a_seach').show();
           $('.search-inp').hide();
           $('.search-inp').val('');
           $('.search-inp').change();
          }
          

        }


            // 侧滑删除
      $(document).on("pagecreate",function(){ 
        $(".chat-list ul li").on("swipeleft",function(){
          $(".chat-list ul li").each(function(i,e){
            $(e).animate({marginLeft:'0rem'},200);
          })
          $(this).animate({marginLeft:'-2rem'},200);
           $('.delete').click(function(){
            $(this).parent('li').animate({marginLeft:'-4rem'},200);
          });
           $('.delete-sure').click(function(){
            $(this).parent('li').remove();
           })

        });
        $(".chat-list ul li").on("swiperight",function(){
          $(this).animate({marginLeft:'0rem'},200);
        });
      });
      // 
      </script>
      <script> 
(function ($) {
  jQuery.expr[':'].Contains = function(a,i,m){
      return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
  };
  function filterList(header, list) { 

  $('.search-inp')
      .change( function () {
        var filter = $(this).val();
        if(filter) {
          $matches = $(list).find('h4:Contains(' + filter + ')').parent().parent().parent();
          $('li', list).not($matches).slideUp();
          $matches.slideDown();
        } else {
          $(list).find("li").slideDown();
        }
        return false;
      })
    .keyup( function () {
        $(this).change();
    });
  }
  $(function () {
    filterList($("#form"), $("#list"));
  });
}(jQuery));

    $('.delete-sure').click(function(){
     //onsole.log(123)
      $(this).parent('li').remove();
      $(this).next().css('display','block');
      $(this).css('display','none');
      var type = $(this).attr('attr_type');
      var id = $(this).attr('attr_id');
      $.post('/home/im/del_friend',{
        type:type,
        id:id
      },function(res){
        // if(res.err==1){
        //   layer.open({
        //   content: res.msg
        //   ,skin: 'msg'
        //   ,time: 1
        //   });
        // }

      })
    });

    </script>

</block>
